package cn.jyc.ssm03.dao;

import cn.jyc.ssm03.pojo.User;
import cn.jyc.ssm03.pojo.UserRole;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserMapper {
    @Select("select * from sys_users")
    public List<User> qryUsers();
    @Select("select * from sys_users where loginname=#{loginname}")
    public List<User> qryUserByName(String loginname);
    @Options(useGeneratedKeys = true, keyProperty = "userid")
    @Insert("insert into sys_users value(null,#{loginname},#{identity},#{realname},#{sex},#{address},#{phone},'123456',#{position})")
    public void addUser(User u);
    @Delete("delete from sys_users where userid = #{userid}")
    public void delUser(Integer uid);
    @Insert("insert into sys_user_role value(#{uid},#{rid})")
    public void addUserRole(UserRole ur);
    @Delete("delete from sys_user_role where uid=#{uid}")
    public void delUserRole(Integer uid);
    @Select("select rid from sys_user_role where uid = #{uid}")
    public List<Integer> qryURoles(Integer uid);
    @Update("update sys_users set loginname=#{loginname},identity=#{identity},realname=#{realname}" +
            ",sex=#{sex},address=#{address},phone=#{phone},pwd=#{pwd},position=#{position} where userid=#{userid}")
    public void updUser(User user);
}
